<template>
    <div class="head">
        <div class="point">
            <svg width="25px" height="25px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
                <title />
                <g id="Complete">
                    <g id="F-Chevron">
                        <polyline fill="none" id="Left" points="15.5 5 8.5 12 15.5 19" stroke="#000000"
                            stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
                    </g>
                </g>
            </svg>
            <svg width="25px" height="25px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
                <title />
                <g id="Complete">
                    <g id="F-Chevron">
                        <polyline fill="none" id="Right" points="8.5 5 15.5 12 8.5 19" stroke="#000000"
                            stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
                    </g>
                </g>
            </svg>

            <!-- 搜索模块 -->
            <div class="search">
                <input type="text" @keydown.enter="goToSearch" v-model="getMusic2.keyword">
                <div class="searchSvg">
                    <svg width="25px" height="25px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                        <path
                            d="M20 20L15.8033 15.8033C15.8033 15.8033 14 18 10.5 18C6.35786 18 3 14.6421 3 10.5C3 6.35786 6.35786 3 10.5 3C14.6421 3 18 6.35786 18 10.5C18 11.0137 17.9484 11.5153 17.85 12"
                            stroke="#000000" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
                    </svg>
                </div>
            </div>
        </div>
        <div class="user">
            <img :src="user.profile.avatarUrl" alt="">
            <p>
                {{ user.profile.nickname }}
            </p>
        </div>
    </div>
</template>

<script setup lang="ts">
import router from '@/router';
import { useUserStore } from '@/stores/user';
import { getMusic } from '@/stores/getMusic'

const getMusic2 = getMusic()
const user = useUserStore()

const goToSearch = async () => {
    router.push({
        name: 'search',
        query: {
            keyword: getMusic2.keyword
        }
    })
    getMusic2.goToSearch(getMusic2.keyword)
}

</script>

<style lang="scss" scoped>
.head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    // background-color: antiquewhite;
    height: 60px;
    // border-bottom: 4px solid var(--rateColor);

    .point {
        max-width: 400px;
        min-width: 100px;
        width: 100%;
        height: 60%;
        display: flex;
        align-items: center;
        margin-left: var(--commonMarginLeft);
        // background-color: antiquewhite;

        svg {
            cursor: pointer;
        }

        .search {
            display: flex;
            align-items: center;
            height: 100%;

            input {
                font-size: 18px;
                margin-left: 20px;
                padding-left: 15px;
                padding-right: 10px;
                min-width: 100px;
                max-width: 200px;
                height: 90%;
                border-top-left-radius: 30px;
                border-bottom-left-radius: 30px;
            }

            .searchSvg {
                display: flex;
                align-items: center;
                height: 90%;
                padding-right: 10px;
                border-top-right-radius: 30px;
                border-bottom-right-radius: 30px;
                background-color: var(--a);
            }
        }



    }

    .user {
        height: 100%;
        min-width: 200px;
        // background-color: antiquewhite;
        display: flex;
        align-items: center;
        justify-content: space-between;
        overflow: hidden;

        // text-align: center;
        p {
            line-height: 40px;
            height: 40px;
            max-width: 200px;
            min-width: 10px;
            width: 100%;
        }

        img {
            margin-right: 20px;
            width: 50px;
            height: 50px;
            border-radius: 50%;
        }
    }
}
</style>